package com.ruoyi.teaching.service.impl;

import java.util.List;

import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.teaching.bo.YaMyStageTaskslBo;
import com.ruoyi.teaching.bo.YaStudentTaskslBo;
import com.ruoyi.teaching.domain.YaStageTaskSubmit;
import com.ruoyi.teaching.mapper.YaStageTaskSubmitMapper;
import com.ruoyi.teaching.vo.YaStudentTasksVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.teaching.mapper.YaStageTasksMapper;
import com.ruoyi.teaching.domain.YaStageTasks;
import com.ruoyi.teaching.service.IYaStageTasksService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 任务Service业务层处理
 * 
 * @author ZBX
 * @date 2025-03-11
 */
@Service
public class YaStageTasksServiceImpl implements IYaStageTasksService 
{
    @Autowired
    private YaStageTasksMapper yaStageTasksMapper;
    @Autowired
    private YaStageTaskSubmitMapper yaStageTaskSubmitMapper;

    /**
     * 查询任务
     * 
     * @param id 任务主键
     * @return 任务
     */
    @Override
    public YaStageTasks selectYaStageTasksById(Long id)
    {
        return yaStageTasksMapper.selectYaStageTasksById(id);
    }

    /**
     * 查询任务列表
     * 
     * @param yaStageTasks 任务
     * @return 任务
     */
    @Override
    public List<YaStageTasks> selectYaStageTasksList(YaStageTasks yaStageTasks)
    {
        return yaStageTasksMapper.selectYaStageTasksList(yaStageTasks);
    }

    /**
     * 新增任务
     * 
     * @param yaStageTasks 任务
     * @return 结果
     */
    @Override
    public int insertYaStageTasks(YaStageTasks yaStageTasks)
    {
        return yaStageTasksMapper.insertYaStageTasks(yaStageTasks);
    }

    /**
     * 修改任务
     * 
     * @param yaStageTasks 任务
     * @return 结果
     */
    @Override
    public int updateYaStageTasks(YaStageTasks yaStageTasks)
    {
        return yaStageTasksMapper.updateYaStageTasks(yaStageTasks);
    }

    /**
     * 批量删除任务
     * 
     * @param ids 需要删除的任务主键
     * @return 结果
     */
    @Override
    public int deleteYaStageTasksByIds(Long[] ids)
    {
        return yaStageTasksMapper.deleteYaStageTasksByIds(ids);
    }

    /**
     * 删除任务信息
     * 
     * @param id 任务主键
     * @return 结果
     */
    @Override
    public int deleteYaStageTasksById(Long id)
    {
        return yaStageTasksMapper.deleteYaStageTasksById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class, readOnly = false)
    public List<YaMyStageTaskslBo> selectYaMyStageTasksList(YaStageTasks yaStageTasks) {

        YaMyStageTaskslBo wrapper = new YaMyStageTaskslBo();
        wrapper.setStudentId(SecurityUtils.getUserId());
        wrapper.setStageName(yaStageTasks.getStageName());
        wrapper.setTaskCode(yaStageTasks.getTaskCode());
        wrapper.setTaskName(yaStageTasks.getTaskName());
        wrapper.setTaskType(yaStageTasks.getTaskType());
        wrapper.setTaskCategory(yaStageTasks.getTaskCategory());
        wrapper.setTaskPriority(yaStageTasks.getTaskPriority());
        return yaStageTasksMapper.selectYaMyStageTasksList(wrapper);
    }

    @Override
    @Transactional(rollbackFor = Exception.class, readOnly = false)
    public List<YaStudentTaskslBo> selectYaStudentTasksSubmitList(YaStudentTasksVo yaStudentTasksVo) {
        return yaStageTasksMapper.selectYaStudentTasksSubmitList(yaStudentTasksVo);
    }

    @Override
    public void checkStudentSubmit(YaStageTaskSubmit yaStageTaskSubmit) {
        yaStageTaskSubmitMapper.updateYaStageTaskSubmit(yaStageTaskSubmit);
    }
}
